package com.sys.gradepaysys.service.impl;

import com.sys.gradepaysys.mapper.AdminMapper;
import com.sys.gradepaysys.model.Admin;
import com.sys.gradepaysys.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class AdminServiceImpl implements AdminService {
    @Autowired
    AdminMapper adminMapper;
    @Override
    public Admin login(String username, String password) {
        Admin admins = adminMapper.selectAdminList(username);
        if (admins != null) {
            if (!admins.getPassword().equals(password)) {
                throw new RuntimeException("密码不正确!");
            }
        } else {
            throw new RuntimeException("该用户不存在!");
        }
        return admins;
    }

    @Override
    public Admin getUserByName(String username) {
        return adminMapper.selectAdminList(username);
    }
}
